class SeedsController < ApplicationController
  def new
    @seed = Seed.new
    @seed.get_seed

    if @seed.save
      json = { ok: true, seed: Digest::SHA2.hexdigest(@seed) }
    else
      json = { ok: false }
    end

    respond_to do |format|
      format.json { render json: json }
    end
  end

  def show
    errors = false
    return unless params[:id] == "remove"
    @seed = Seed.all(s: params[:s]).first
    if @seed
      @seed.destroy
    else
      errors = true
    end

    respond_to do |format|
      format.json { render json: {e: errors} }
    end
  end

end
